package com.nf.action;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Controller;

@Aspect
@Controller
public class Dog {
    //切点表达式
    @Pointcut("execution(* com.nf.action.*.*(..))")
    public void test() {
    }
    //公共的拦截器
    @Around("test()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        if (pjp.getTarget() instanceof com.nf.action.Login_Exit_action){
            System.out.println("不用拦截");
            Object result= pjp.proceed();
            return result;
        }else{
            System.out.println("拦截");
            Object[] args = pjp.getArgs();
            for (Object secesion:args){
                if (secesion==null){
                    return "redirect:Login?message=LOGIN_TIME_OUT";
                }
            }
        }
        Object result= pjp.proceed();
        return result;
    }

}
